package com.itrus.cvm;

import com.itrus.cert.X509Certificate;
import com.itrus.util.RegexUtils;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchProviderException;
import java.security.cert.CertificateException;
import java.util.Hashtable;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class CVMConfigFactory
{
  private static Log log = LogFactory.getLog("ITRUS-CVM");

  public Hashtable getCRLContextHashtable(String paramString)
    throws ParserConfigurationException, SAXException, IOException, CertificateException, NoSuchProviderException
  {
    Hashtable localHashtable = new Hashtable();
    String str1 = "（配置文件：" + paramString + "）";
    File localFile = new File(paramString);
    String str2 = localFile.getParent();
    NodeList localNodeList = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(localFile).getElementsByTagName("CRLContext");
    boolean bool1 = false;
    int i = 0;
    int j = localNodeList.getLength();
    if (i >= j)
      return localHashtable;
    Element localElement = (Element)localNodeList.item(i);
    String str4;
    if (localElement.getElementsByTagName("CaFileName").getLength() >= 1)
    {
      str4 = str2 + System.getProperty("file.separator") + localElement.getElementsByTagName("CaFileName").item(0).getFirstChild().getNodeValue().trim();
      if (!RegexUtils.matchesIgnoreCase(str4, ".*(.cer|.crt|.pem)$"))
      {
        String str11 = "<CaFileName>必须是后缀名为.cer或者.crt或者.pem的证书文件！" + str1;
        IOException localIOException2 = new IOException(str11);
        throw localIOException2;
      }
    }
    else
    {
      String str3 = "<CRLContext>必须配置<CaFileName>！" + str1;
      IOException localIOException1 = new IOException(str3);
      throw localIOException1;
    }
    int k = localElement.getElementsByTagName("CrlUrl").getLength();
    String str5 = null;
    if (k >= 1)
      str5 = localElement.getElementsByTagName("CrlUrl").item(0).getFirstChild().getNodeValue().trim();
    int m = localElement.getElementsByTagName("CrlFileName").getLength();
    String str6 = null;
    if (m >= 1)
      str6 = str2 + System.getProperty("file.separator") + localElement.getElementsByTagName("CrlFileName").item(0).getFirstChild().getNodeValue().trim();
    label452: String str7;
    boolean bool2;
    label577: int[] arrayOfInt;
    String[] arrayOfString;
    if (localElement.getElementsByTagName("NotCheckCRL").getLength() >= 1)
    {
      String str10 = localElement.getElementsByTagName("NotCheckCRL").item(0).getFirstChild().getNodeValue();
      if ((str10 != null) && (str10.equalsIgnoreCase("true")))
        bool1 = true;
    }
    else
    {
      int n = localElement.getElementsByTagName("AccountHash").getLength();
      str7 = null;
      if (n >= 1)
        str7 = localElement.getElementsByTagName("AccountHash").item(0).getFirstChild().getNodeValue().trim();
      int i1 = localElement.getElementsByTagName("TimingDownload").getLength();
      bool2 = false;
      if (i1 >= 1)
      {
        String str9 = localElement.getElementsByTagName("TimingDownload").item(0).getFirstChild().getNodeValue();
        if ((str9 == null) || (!str9.equalsIgnoreCase("true")))
          break label809;
        bool2 = true;
      }
      arrayOfInt = (int[])null;
      if (localElement.getElementsByTagName("RetryPolicy").getLength() >= 1)
      {
        String str8 = localElement.getElementsByTagName("RetryPolicy").item(0).getFirstChild().getNodeValue().trim();
        if (str8 != null)
        {
          arrayOfString = str8.split(",");
          arrayOfInt = new int[arrayOfString.length];
        }
      }
    }
    for (int i2 = 0; ; i2++)
    {
      int i3 = arrayOfString.length;
      if (i2 >= i3)
      {
        CRLContextConfInfo localCRLContextConfInfo = new CRLContextConfInfo();
        localCRLContextConfInfo.setCAFilePath(str4);
        localCRLContextConfInfo.setCRLFilePath(str6);
        if (str5 != null)
          localCRLContextConfInfo.setCRLUrl(str5);
        if (arrayOfInt != null)
          localCRLContextConfInfo.setRetryPolicy(arrayOfInt);
        localCRLContextConfInfo.setNotCheckCRL(bool1);
        localCRLContextConfInfo.setAccountHash(str7);
        localCRLContextConfInfo.setTimingDownload(bool2);
        CRLContext localCRLContext = new CRLContext(localCRLContextConfInfo);
        log.debug("增加CA支持[" + localCRLContext.getCaCert().getSubjectDNString() + "]");
        localHashtable.put(localCRLContext.getCaCert().getSubjectDNString(), localCRLContext);
        i++;
        break;
        bool1 = false;
        break label452;
        label809: bool2 = false;
        break label577;
      }
      arrayOfInt[i2] = Integer.parseInt(arrayOfString[i2].trim());
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.itrus.cvm.CVMConfigFactory
 * JD-Core Version:    0.6.2
 */